import * as React from 'react';
import { Point, Range, OperaType } from '../../reducer/const';
import { PathString } from '../../util/eventUtil';

import { INodeProps } from './TaskNode';
import BranchNode from './BranchNode';


export default class SyncNode extends BranchNode {

    constructor(props: INodeProps) {
        super(props);
        this.strokeIconWidth = 2;
    }


    getIconAttr() {
        const iconAttr = { 'stroke': `${this.colorIcon}`, 'fill': `none`, 'stroke-width': `${this.strokeIconWidth}`, 'transform': `${300}` };
        return iconAttr;
    }

    getIconPath(range: Range) {
        const r = 8;
        const offsetAng = 25;
        const center: Point = new Point(range.x + range.height / 2, range.y + range.height / 2);
        const pathString: PathString = new PathString();
        let point: Point = new Point(center.x + r * Math.cos((-180 + offsetAng) * 3.14 / 180), center.y + r * Math.sin((-180 + offsetAng) * 3.14 / 180));
        pathString.M(point);
        for (let ang = -180 + offsetAng; ang <= 0; ang += 5) {
            point = new Point(center.x + r * Math.cos(ang * 3.14 / 180), center.y + r * Math.sin(ang * 3.14 / 180));
            pathString.L(point);
        }
        pathString.M(point.x - 4, point.y - 2).L(point.x, point.y).L(point.x + 2, point.y - 4);

        point = new Point(center.x + r * Math.cos((offsetAng) * 3.14 / 180), center.y + r * Math.sin((offsetAng) * 3.14 / 180));
        pathString.M(point);
        for (let ang = offsetAng; ang <= 180; ang += 5) {
            point = new Point(center.x + r * Math.cos(ang * 3.14 / 180), center.y + r * Math.sin(ang * 3.14 / 180));
            pathString.L(point);
        }
        pathString.M(point.x - 2, point.y + 4).L(point.x, point.y).L(point.x + 4, point.y + 2);

        return pathString.toString();
    }



}
